package com.grass.cropTradingCenter.controller.user;


import com.grass.cropTradingCenter.common.Result;
import com.grass.cropTradingCenter.pojo.entity.UserOrder;
import com.grass.cropTradingCenter.pojo.vo.user.QueryOrderVo;
import com.grass.cropTradingCenter.pojo.vo.user.SaveOrderVo;
import com.grass.cropTradingCenter.service.UserOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/user/order")
@Api(tags = "用户 -- 订单接口")
public class OrderController {
    @Autowired
    UserOrderService userOrderService;

    @PostMapping("/saveOrder")
    @ApiOperation("创建订单")
    public Result saveOrder(@RequestBody SaveOrderVo vo) {
        userOrderService.saveOrder(vo);
        return Result.success();
    }

    @PostMapping("/orderList")
    @ApiOperation("获取个人订单列表")
    public Result<List<UserOrder>> getOrderList(@RequestBody QueryOrderVo vo) {

        return Result.success(userOrderService.getOrderList(vo));
    }

    @PostMapping("/confirmSH/{id}")
    @ApiOperation("确认收货")
    public Result confirmSH(@PathVariable("id") Integer id) {
        userOrderService.confirmSH(id);
        return Result.success();
    }

}
